home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group92c.txt / 000058_icon-group-sender _Wed Nov 4 07:05:19 1992.msg < prev    next >
Internet Message Format  |  1993-01-04  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Wed, 4 Nov 1992 09:05:46 MST
  2. Date: Wed, 4 Nov 92 15:03 MET
  3. From: JANPETER@mpi.nl
  4. Subject: file scanning
  5. To: icon-group@cs.arizona.edu
  6. Message-Id: <01GQRAOSOAB48WWBJA@KUNRC1.URC.KUN.NL>
  7. X-Envelope-To: icon-group@cs.arizona.edu
  8. X-Vms-To: IN%"icon-group@cs.arizona.edu"
  9. Comments: Sent using PMDF-822 V3.0, routing is done by KUNRC1
  10. Status: R
  11. Errors-To: icon-group-errors@cs.arizona.edu
  12.  
  13. Richard Goerwitz writes:
  14.  
  15. >One thing that's worth thinking about is whether string scanning could
  16. >be extended to cover files.  That would solve your problem.  Seems
  17. >like a great idea to me.  Really great.  It's something the Icon Pro-
  18. >ject has been talking about.  Any bright students at the U of Arizona
  19. >looking for class projects :-).  Would take some interesting buffering
  20. >and a lot of fseeks.  But wouldn't it be neat to have scanning usable
  21. >on character streams as well as strings?
  22.  
  23. This was somewhat surprising to me, because I already do string
  24. scanning on files. I'll explain how, and I'm eager to receive
  25. comments on the proposed method. The method works great on Ultrix,
  26. and MSDOS (386) platforms, so I gather it's kosher Icon. The basic
  27. tric is to use the ! generator twice.
  28.  
  29. Suppose we just want to print all successive characters in a text file.
  30. The text file is:
  31.  
  32. <begin file>
  33. The man the woman the
  34. dog bit hit chose to be free.
  35. <end file>
  36.  
  37. Now one way to scan the entire file (as if it's one string, so
  38. to speak) is this:
  39.  
  40. procedure main()
  41.   inputfile := open("filename")
  42.   !!inputfile ? while write(move(1))
  43. end
  44.  
  45. the output is:
  46. The man the woman thedog bit hit chose to be free.
  47.  
  48. If this looks simple, that's because it is simple, but I wonder:
  49. Is this what is meant by scanning a character stream, or have I
  50. understood the problem wrongly?
  51.  
  52. Jan P. de Ruiter
  53. Max Planck Institute for Psycholinguistics
  54. janpeter@mpi.nl
  55.  
  56.